package my.algo;

public class 左移右移 {

    public static void main(String[] args) {
        int value = 733183670;
        // 左移 正负可能会转换
        System.out.println("=============左移============");
        System.out.println(Integer.toBinaryString(value));
        System.out.println((value << 1) + " == " + (value * 2));
        System.out.println(Integer.toBinaryString(value << 1));
        System.out.println((value << 8) + " == " + (value * Math.pow(2, 8)));
        System.out.println(Integer.toBinaryString(value << 8));
        // 右移和无符号右移
        System.out.println("=============右移============");
        System.out.println((value >> 1) + " == " + (value / 2));
        System.out.println(Integer.toBinaryString(value >> 1));
        value = -value;
        System.out.println(value >> 1);
        System.out.println(value >>> 1);
    }
}
